package com.ithei.user;

import com.alibaba.fastjson.JSON;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

public class YongYouDemo {
    @Test
    public void idCardCheck() {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders httpHeaders = new HttpHeaders();
        httpHeaders.set("apicode", "91eb9a0e88f14fb2b05683cfbc3726f2");
        httpHeaders.setContentType(MediaType.APPLICATION_JSON);
        Map map = new HashMap<>();
        map.put("idNumber", "132456");
        map.put("username", "123");
        HttpEntity<String> formEntry = new HttpEntity<>(JSON.toJSONString(map), httpHeaders); // 封装请求参数
        ResponseEntity<String> response = restTemplate.postForEntity("https://api.yonyoucloud.com/apis/dst/matchIdentity/matchIdentity?", formEntry, String.class);// 发送一个post请求
        System.out.println(response);
    }

    private Map excutePost(String apicode, Map params, String url) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders httpHeaders = new HttpHeaders();
        httpHeaders.set("apicode", apicode);
        httpHeaders.setContentType(MediaType.APPLICATION_JSON);

//        HttpEntity<String> formEntry = new HttpEntity<>(JSON.toJSONString(), httpHeaders); // 封装请求参数
//        ResponseEntity<String> response = restTemplate.postForEntity("https://api.yonyoucloud.com/apis/dst/matchIdentity/matchIdentity?", formEntry, String.class);// 发送一个post请求
        return null;
    }

    private Boolean idCard() {
        return null;
    }
}
